<?php

namespace app\validate;

use think\Validate;

class Post extends Validate
{
    //验证规则
    protected $rule = [];

    // create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data', 'require|array')
            ->append('data.name', 'require|max:255')
            ->append('data.item_id', 'require')
            ->append('data.catalog_id', 'require');
    }

    // update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data', 'require|array')
            ->append('data.id', 'require')
            ->append('data.name', 'max:255');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter.id', 'require');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'require|array')
            ->append('param.page', 'array');
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'require|array');
    }

    //创建知识本内容页
    public function sceneCreateKnowledgeBookPage()
    {
        return $this->append('data', 'require')
            ->append('data.name', 'require')
            ->append('data.item_id', 'require');
    }

    public function sceneUpdateKnowledgeBookPage()
    {
        return $this->append('data', 'require')
            ->append('data.id', 'require');
    }

    public function sceneDeleteKnowledgeBookPage()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'require');
    }
}
